#ifndef MAIN_H
#define MAIN_H

#include <GL/glew.h>
#include <GL/glut.h>

#include "Body.h"
#include "Particle.h"
#include "Timer.h"
#include "Grid.h"

int windowWidth = 1024;
int windowHeight = 768;

int oldMouseX;
int oldMouseY;
bool leftButtonPressed = false;
bool rightButtonPressed = false;

/* Changing the values here alters the initial camera view */
float rotateX = 20.0f;
float rotateY = -45.0f;
float translateZ = -30.0f;
float translateY = -5.0f;

bool onlyDrawParticles = false;

float worldSize = 15.0f; //Half length of world

GLfloat ground[4][3] = { /* Ground plane vertex positions */
	{ -worldSize, 0.0, -worldSize }, { -worldSize, 0.0, worldSize },
	{ worldSize, 0.0, worldSize }, { worldSize, 0.0, -worldSize } };
GLfloat groundNormal[3] = { 0.0, 1.0, 0.0 };

int totalNumberOfBodies;
Body** bodies;
int totalNumberOfParticles;
Particle** particles;

Timer* timer;

//Simulation parameters
float springCoefficient = 100.0f;
float dampingCoefficient = 0.5f;
float timeDelta = 0.01f;
float particleRadius = 0.20;
float terminalVelocity = 20.0f;

//Grid data structures
int* indexGrid;
int* countGrid;
float voxelSize;
int particlesPerVoxel = 4;
float gridMinimumPosition;
int gridLength;

//VBO data structures
GLuint vbo;
int vertexCount;
float* vertexData;
float* normalData;
float* colorData;
float* particleVertexData;
float* particleColorData;

//Function declarations

void mouseFunc(int button, int state, int x, int y);
void resetSimulation1();
void resetSimulation2();
void motionFunc(int x, int y);
void keyboardFunc(unsigned char key, int x, int y);
void stepSimulation(float delta);
void drawGroundPlane();
void reshapeFunc(int w, int h);
void drawParticles();
void drawBodies();
void display();
void initGL();
void initSimulation();

#endif
